Skip to content

Modernize Python packaging using uv and pyproject.toml#225

Open
gdevenyi wants to merge 8 commits intomasterfrom
modernize-packaging-with-uv
Open

Modernize Python packaging using uv and pyproject.toml#225
gdevenyi wants to merge 8 commits intomasterfrom
modernize-packaging-with-uv

Conversation

@gdevenyi
Copy link
Member

@gdevenyi gdevenyi commented Feb 6, 2026

This PR updates the project to use modern Python packaging standards with uv as the package manager and drops Python 2 support.

Changes:

  • Add pyproject.toml with modern PEP 621 metadata
  • Replace setup.py, setup.cfg, requirements*.txt with pyproject.toml
  • Drop Python 2 support (requires Python 3.8+)
  • Remove 'future' dependency (no longer needed)
  • Migrate tests from nose to pytest
  • Remove Python 2 compatibility code from source files
  • Update .gitignore with modern Python/uv patterns

All 10 tests pass with pytest.

Summary by CodeRabbit

  • Chores

    • Project is Python‑3 only: legacy Python‑2 shims and test deps removed.
    • Packaging migrated to pyproject (Hatch); legacy setup files removed and entry points updated.
    • CI and publishing moved to new tooling; Travis config removed and workflow simplified.
    • Repository ignore rules expanded and test dependency list trimmed.
  • Documentation

    • Added a developer guidance document; updated project citation/version and removed old CI badge.

This PR updates the project to use modern Python packaging standards
with uv as the package manager and drops Python 2 support.

Changes:
- Add pyproject.toml with modern PEP 621 metadata
- Replace setup.py, setup.cfg, requirements*.txt with pyproject.toml
- Drop Python 2 support (requires Python 3.8+)
- Remove 'future' dependency (no longer needed)
- Migrate tests from nose to pytest
- Remove Python 2 compatibility code from source files
- Update .gitignore with modern Python/uv patterns

All 10 tests pass with pytest.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad92960 and 923bbb9.

📒 Files selected for processing (1)
  • CITATION.cff

📝 Walkthrough

Walkthrough

Removes Python 2 compatibility shims, migrates packaging to Hatch via pyproject.toml (removing setup.py/setup.cfg flags), replaces Travis CI with an UV-based GitHub Actions publish workflow, adjusts requirements and .gitignore, and adds CLAUDE.md. No public API changes.

Changes

Cohort / File(s) Summary
Build system & packaging
setup.py, setup.cfg, pyproject.toml
Deleted legacy setup.py and some setup.cfg flags; added pyproject.toml (Hatch) with project metadata, build targets, sdist/wheel config, and console script entry.
CI / Publish workflow
.travis.yml, .github/workflows/publish.yml
Removed .travis.yml; updated GH Actions publish workflow to use setup-uv and uv build/uv publish, adjusted action versions, cache, and permissions.
Compatibility cleanup
qbatch/__init__.py, qbatch/qbatch.py, test/test_qbatch.py
Removed __future__ imports and Python 2 shims (env normalization); simplified imports and removed Python 2-specific test scaffolding.
Requirements
requirements.txt, requirements-testing.txt, pyproject.toml
Removed future from runtime requirements and nose, future, ushlex from testing requirements; testing deps moved/declared under pyproject.toml.
Repo metadata & docs
CITATION.cff, README.md, CLAUDE.md
Updated CITATION.cff repo/version/date; removed Travis badge from README; added CLAUDE.md with development and architecture guidance.
Ignore rules
.gitignore
Removed .eggs/ and qbatch.egg-info/ entries and expanded ignore patterns for Python artifacts, virtualenvs, packaging, uv, IDE, and OS files.
Tests
test/test_qbatch.py
Docstring repo URL updated; removed Python 2 boilerplate and environment handling; test logic otherwise unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as "Developer / Push"
  participant GH as "GitHub Actions"
  participant UV as "setup‑uv / uv"
  participant Registry as "Package Registry"

  Dev->>GH: push tag / release
  GH->>GH: checkout repo
  GH->>UV: setup‑uv (enable-cache)
  GH->>UV: uv build
  UV->>Registry: uv publish
  Registry-->>GH: publish result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I dropped old shims and hopped to a new hill,
Hatch stitched the packets with a tiny thrill.
Travis took a bow, UV sings instead,
CLAUDE left a note beside my bed.
Happy hops — the repo is bright and still.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: modernizing Python packaging with uv and pyproject.toml, which aligns with the primary objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch modernize-packaging-with-uv

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@CLAUDE.md`:
- Around line 101-122: Update the README sections to match this PR’s
modernization: remove the entire "Python 2/3 Compatibility" section, change the
"Testing Notes" text to say tests use pytest instead of nosetests and drop any
mention of the `future` library, and update the "Version Management" section to
state that the project version is defined in pyproject.toml rather than
setup.py; edit the sections titled "Testing Notes", "Python 2/3 Compatibility"
(remove), and "Version Management" accordingly.
- Around line 23-39: Update the Build and Installation command examples in
CLAUDE.md to use the new pyproject/uv workflow instead of removed setup.py and
requirements-testing.txt: replace the "python setup.py sdist bdist_wheel" line
with "uv build", change "pip install -e ." under Build to "uv pip install -e .",
change "pip install ." under Installation to "uv pip install .", and replace the
"pip install -r requirements-testing.txt" test deps line with "uv sync --group
testing" (also adjust the accompanying comment to indicate dev/testing
dependencies).
- Around line 12-21: Update the testing examples in CLAUDE.md to use pytest
instead of nosetests: replace "nosetests test/test_qbatch.py" with "pytest
test/test_qbatch.py", change the specific-test syntax from "nosetests
test/test_qbatch.py:test_run_qbatch_local_piped_commands" to the pytest style
"pytest test/test_qbatch.py::test_run_qbatch_local_piped_commands", and update
the verbose example from "nosetests -v test/test_qbatch.py" to "pytest -v
test/test_qbatch.py"; ensure the three example lines referencing
test/test_qbatch.py are edited accordingly.

In `@pyproject.toml`:
- Around line 50-54: The [project.optional-dependencies] testing group still
lists legacy packages "nose>=1.0" and "ushlex"; remove that stale testing table
or replace its contents to match the modern pytest setup under
[dependency-groups] (testing) so that pip install qbatch[testing] pulls the
correct pytest dependencies—specifically delete or update the
[project.optional-dependencies] testing block to either be removed entirely or
to reference the same pytest packages declared in [dependency-groups] testing.

@gdevenyi gdevenyi assigned CMonnin and unassigned CMonnin Feb 6, 2026
@gdevenyi gdevenyi requested a review from CMonnin February 6, 2026 00:26
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gdevenyi gdevenyi force-pushed the modernize-packaging-with-uv branch from 1d07e11 to cbb2f27 Compare February 6, 2026 17:23
The testing group referenced nose and ushlex, which are Python 2-era
packages no longer used. The correct pytest dependencies are already
declared in [dependency-groups] testing.

This addresses the remaining CodeRabbit comment on PR #225.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/publish.yml:
- Around line 19-24: Update the GitHub Actions step that currently uses
astral-sh/setup-uv@v4 (the "Install uv" step) to a newer major version by
replacing the pinned action version with at least `@v7` (preferably `@v7.3.0`); keep
the same inputs (enable-cache: true) and the subsequent "Build package" run step
that invokes uv build unchanged so the workflow uses the latest security fixes
and improvements.
🧹 Nitpick comments (2)
CLAUDE.md (2)

47-48: Hard-coded line count will go stale.

Line 47 references "777 lines" for qbatch.py. This will become inaccurate as the file evolves. Consider removing the exact count or replacing it with a qualitative description (e.g., "single large module").

Similarly, lines 52, 57, 64–68 reference specific line numbers for functions and templates — these will drift with edits.


32-39: Minor: Installation section shows both pip and uv pip without guidance on which to prefer.

Since this PR adopts uv as the package manager, consider indicating that uv pip install . is the preferred approach, or consolidate the two options with a brief note (e.g., "either works; uv is recommended").

Copy link
Member

@CMonnin CMonnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small fixes/tweaks to publish.yml pushed in commit ecd8ed4

@@ -16,16 +16,11 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkout@v6

- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv@v7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update to the newest setup-uv

run: |
python setup.py sdist bdist_wheel # Could also be python -m build
run: uv build
- name: Publish package distributions to PyPI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use uv publish

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update this to use the uv publish workflow

@@ -16,16 +16,11 @@ jobs:
id-token: write
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv docs have
contents: read
too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot make this change

Copy link

Copilot AI commented Feb 23, 2026

@gdevenyi I've opened a new pull request, #227, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the repo’s Python packaging by moving to pyproject.toml (Hatchling) with uv-based workflows, while removing Python 2 compatibility code and legacy packaging/testing infrastructure.

Changes:

  • Replace legacy packaging files (setup.py, setup.cfg, requirements*.txt) with a PEP 621 pyproject.toml.
  • Remove Python 2 compatibility shims from the library and tests; drop future/ushlex/nose-era dependencies.
  • Update automation/docs/metadata (GitHub publish workflow, .gitignore, README links, citation metadata, new CLAUDE.md).

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Introduces modern project metadata, build backend (Hatchling), scripts, and dependency groups.
.github/workflows/publish.yml Switches release publishing to uv build / uv publish.
qbatch/qbatch.py Removes Python 2 compatibility imports and environment encoding workaround.
qbatch/__init__.py Drops Python 2 __future__ import.
test/test_qbatch.py Removes Python 2 compatibility setup and updates issue link.
.gitignore Expands ignores for common Python/venv/test/build artifacts and uv files.
README.md Updates Travis badge repository path.
CITATION.cff Updates repository URL.
CLAUDE.md Adds developer-oriented guidance and project architecture notes.
setup.py Removed legacy setuptools packaging entrypoint.
setup.cfg Removed legacy wheel/metadata config.
requirements.txt Removed legacy runtime dependency pin.
requirements-testing.txt Removed legacy test dependency list.
.travis.yml Removes Travis CI configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CITATION.cff Outdated
Comment on lines 18 to 19
version: "2.2"
date-released: 2020-03-12
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repository-code was updated, but version/date-released still reflect the 2020 (2.2) release, which is inconsistent with the current package version in pyproject.toml (2.3.1). Please update these fields (or remove them) so the citation metadata matches the current release.

Suggested change
version: "2.2"
date-released: 2020-03-12

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update to the proper dates/versions

gdevenyi and others added 2 commits February 23, 2026 14:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Mar 2, 2026

@gdevenyi I've opened a new pull request, #228, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Mar 2, 2026

@gdevenyi I've opened a new pull request, #229, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI mentioned this pull request Mar 2, 2026
Copy link

Copilot AI commented Mar 2, 2026

@gdevenyi I've opened a new pull request, #230, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,8 +1,4 @@
#!/usr/bin/env python
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that Python 2 support is dropped (requires Python 3.8+), the #!/usr/bin/env python shebang can still resolve to Python 2 on some systems. Consider switching the shebang to python3 (or removing it if this module is not intended to be executed directly) to avoid accidental Python 2 execution.

Suggested change
#!/usr/bin/env python
#!/usr/bin/env python3

Copilot uses AI. Check for mistakes.
@@ -1,45 +1,10 @@
#!/usr/bin/env python
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test module still has a #!/usr/bin/env python shebang even though the project is now Python 3-only. If the file is ever executed directly, it may run under Python 2 on some systems; consider updating it to python3 (or dropping the shebang) for consistency with the supported runtimes.

Suggested change
#!/usr/bin/env python
#!/usr/bin/env python3

Copilot uses AI. Check for mistakes.
Co-authored-by: gdevenyi <3001850+gdevenyi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants